/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package battle.ship.model;

import java.util.Arrays;
import java.util.Random;

/**
 *
 * @author Carlos
 */
public class ComputerPlayer extends Player{

    public ComputerPlayer() {
        super("Manecas");
        this.FillBoard();
    }
    
        public Move play() {
        int size = this.board.getSize();
        Random rand = new Random();
        Move move;
        do {
            move = new Move (rand.nextInt(size + 1),
                rand.nextInt(size + 1));
        } while (this.moves.contains(move));
        return move;
    }
    
    @SuppressWarnings("empty-statement")
    private void FillBoard(){
        if(this.board!=null){
            while (!this.board.addShip(new Submarine(Arrays.asList(Point.Random(10))))){};
            while (!this.board.addShip(new Submarine(Arrays.asList(Point.Random(10))))){};
        }
    }
}
